<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Pageadver;
use Illuminate\Http\Request;

class PageadverController extends Controller
{
    public function __construct()
    {
        $this->middleware('grant:pageadver');
    }

    /**
     * 进入页面广告图片列表页面
     */
    public function getIndex()
    {
        return view('admin/pageadver/index');
    }

    /**
     * 进入添加页面
     */
    public function getAdd()
    {
        $token = session('token');
        if ($token['isHidden'] == false) {
            return $this->warning('无此操作权限！');
        }
        return view('admin/pageadver/add');
    }

    /**
     * 进入编辑页面
     */
    public function getEdit(Request $request)
    {
        $id = intval($request->input('id'));
        $row = Pageadver::find($id);
        if (empty($row)) {
            return $this->warning('无效的记录');
        }
        return view('admin/pageadver/edit', $row);
    }
}
